Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/vnf skeleton #5

Merged
merged 40 commits into from
Sep 23, 2024
Merged

Feature/vnf skeleton #5

merged 40 commits into from
Sep 23, 2024

Conversation

Laurynas-Jagutis
Copy link
Member

No description provided.

Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
@Laurynas-Jagutis Laurynas-Jagutis added the feature New feature or request label Sep 6, 2024
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i cannot review more than this cause it's a fundamental design issue

Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
@Laurynas-Jagutis
Copy link
Member Author

Laurynas-Jagutis commented Sep 11, 2024

We haven't introduced any checks to skip from checking for clang tidy. Probably we can take the ones from PGM, most of clang tidy complaints should be fixed that way.

@mgovers
Copy link
Member

mgovers commented Sep 11, 2024

We haven't introduced any checks to skip from checking for clang tidy. Probably we can take the ones from PGM, most of clang tidy complaints should be fixed that way.

I propose only disabling the checks that are disablef in pgm and that also complain on this repo. New code should be better bu default, and case-by-case disabled at worst

Copy link
Contributor

@Jerry-Jinfeng-Guo Jerry-Jinfeng-Guo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the skeleton will be pretty much ok when those minor issues are polished. Also pay attention to the east const, which we take as standard inside PGM.

Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
@Laurynas-Jagutis
Copy link
Member Author

I believe sonar cloud complaints are in a way false positive.
Complains for const are there just because our functions are empty, after we fill them in, we should decide whether they need constness or not. I do not think that there is a point to add constness to functions that might not be const.

Complaints for new and delete are also not accurate I think. It would prefer if we used memory management techniques which automatically manage the memory, but they free up the memory when going out of scope. So if the scope is a function where we created the pointer, after that function it would be destroyed. While in our example, we have 3 api functions which all need the same pointer.

I can't add to much towards arguing for reinterpret_cast, but it is used when casting from one pointer to another, useful in opaque pointers.

@Laurynas-Jagutis Laurynas-Jagutis marked this pull request as ready for review September 23, 2024 07:15
@Jerry-Jinfeng-Guo
Copy link
Contributor

I believe sonar cloud complaints are in a way false positive. Complains for const are there just because our functions are empty, after we fill them in, we should decide whether they need constness or not. I do not think that there is a point to add constness to functions that might not be const.

You are right. Feel free to disable those false positives if you are certain.

Complaints for new and delete are also not accurate I think. It would prefer if we used memory management techniques which automatically manage the memory, but they free up the memory when going out of scope. So if the scope is a function where we created the pointer, after that function it would be destroyed. While in our example, we have 3 api functions which all need the same pointer.

Same goes here.

@figueroa1395
Copy link
Contributor

Complains for const are there just because our functions are empty, after we fill them in, we should decide whether they need constness or not. I do not think that there is a point to add constness to functions that might not be const.

That is fair. It can be re-evaluated when the actual implementation is made.

Complaints for new and delete are also not accurate I think. It would prefer if we used memory management techniques which automatically manage the memory, but they free up the memory when going out of scope. So if the scope is a function where we created the pointer, after that function it would be destroyed. While in our example, we have 3 api functions which all need the same pointer.

This may be resolved once the actual implementation of the VNF converter class is implemented, as the memory management can be dealt with there in a safer way. For now, it should be okay.

I can't add to much towards arguing for reinterpret_cast, but it is used when casting from one pointer to another, useful in opaque pointers.

There is nothing much we can really do here, that is how C APIs work.

On the other hand, when we leave so many un-resolved smells on purpose, do we have a way to go about it at the moment? This can be easily forgotten, or at least the reasoning behind it. Maybe @Jerry-Jinfeng-Guo or @mgovers can comment on this?

Copy link
Contributor

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall.

@Jerry-Jinfeng-Guo
Copy link
Contributor

On the other hand, when we leave so many un-resolved smells on purpose, do we have a way to go about it at the moment? This can be easily forgotten, or at least the reasoning behind it. Maybe @Jerry-Jinfeng-Guo or @mgovers can comment on this?

@figueroa1395 The priority now is push forward this project. Most of the sonar cloud issues are indeed false positive if we inspect them case by case. Being stuck at polishing at such an early stage is not only counterproductive but can also be frustrating for @Laurynas-Jagutis . Therefore, I would argue for pushing forward so long as the direction is correct.

@figueroa1395
Copy link
Contributor

@figueroa1395 The priority now is push forward this project. Most of the sonar cloud issues are indeed false positive if we inspect them case by case. Being stuck at polishing at such an early stage is not only counterproductive but can also be frustrating for @Laurynas-Jagutis . Therefore, I would argue for pushing forward so long as the direction is correct.

I agree. And it should not be a blocker specially at this stage. Maybe I phrased my words wrong. I was just raising it such that we can create an action point to make agreements (if not present yet) to know how to handle it in the future. But I think we can just ignore them for this PR.

Signed-off-by: Laurynas Jagutis <[email protected]>
Signed-off-by: Laurynas Jagutis <[email protected]>
@Laurynas-Jagutis Laurynas-Jagutis dismissed mgovers’s stale review September 23, 2024 12:05

The changes have taken place, another person will approve this pull request

Signed-off-by: Laurynas Jagutis <[email protected]>
.gitmodules Outdated
url = [email protected]:PowerGridModel/power-grid-model.git
[submodule "deps/power-grid-model"]
path = deps/power-grid-model
url = https://github.com/PowerGridModel/power-grid-model.git
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a second thought, please update this line to use the ssh protocal

Suggested change
url = https://github.com/PowerGridModel/power-grid-model.git
url = git@github.com:PowerGridModel/power-grid-model.git

Copy link
Member

@mgovers mgovers Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not all our users may have SSH installed. In addition, it is and open-source, so security is also not an issue on that side.

The HTPPS protocol is actually probably desired... @Jerry-Jinfeng-Guo what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally agree on the esay to use side of https. We can change it back in the next PR. I was just under the impression that open source project tend to prefer ssh because it is cool

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

@@ -20,6 +20,7 @@ sonar.sourceEncoding=UTF-8
sonar.issue.ignore.allfile=a1
sonar.issue.ignore.allfile.a1.fileRegexp='.*#include.*doctest\.h[>"].*'
sonar.coverage.exclusions="tests/**/*"
sonar.coverage.exclusions=power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp,power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a todo here as well:

Suggested change
sonar.coverage.exclusions=power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp,power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp
# TODO(Laurynas-Jagutis) remove temporary scan disables
sonar.coverage.exclusions=power_grid_model_io_native_c/power_grid_model_io_native/include/power_grid_model_io_native/vnf_converter/vnf_pgm_converter.hpp,power_grid_model_io_native_c/power_grid_model_io_native_c/src/vnf_pgm_converter.cpp

Copy link

Copy link
Contributor

@figueroa1395 figueroa1395 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the comments have been addressed, so I approve.

@Laurynas-Jagutis Laurynas-Jagutis added this pull request to the merge queue Sep 23, 2024
Merged via the queue into main with commit 169272d Sep 23, 2024
25 checks passed
@Laurynas-Jagutis Laurynas-Jagutis deleted the feature/vnf-skeleton branch September 23, 2024 13:40
Copy link
Member

@mgovers mgovers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good progress. really happy you were able to get this in a good state without needing my input!

Comment on lines +32 to +34
find_package(Eigen3 CONFIG REQUIRED)
find_package(Boost REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not trying to revert this PR, but do you need to find these again? since the PGM core already hard-depends on this, you already have this from that location. Even more so, you're now actually overwriting the Eigen3_FOUND, Boost_FOUND and nlohmann_json_FOUND variables (and everything related). I think this is both redundant and actually more error-prone.

void convert_links_input();
};

inline PgmVnfConverter::PgmVnfConverter(char* buffer, power_grid_model::WritableDataset* data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a particular reason why you went with out-of-line implementations instead of in-class implementations (as we do in the PGM):

class PgmVnfConverter {
  public:
    PgmVnfConverter(char* buffer = nullptr, power_grid_model::WritableDataset* data = nullptr) 
        : f_file_buffer(buffer), deserialized_data(data) {
            using namespace std::string_literals;
            using power_grid_model::ExperimentalFeature;
            throw ExperimentalFeature{"PGM_VNF_converter", ExperimentalFeature::TypeValuePair{.name = "PGM_VNF_conversion",
                                                                                              .value = std::to_string(1)}};
    }

    // the rest of the functions
    // ...
};

@mgovers
Copy link
Member

mgovers commented Sep 24, 2024

I can't add to much towards arguing for reinterpret_cast, but it is used when casting from one pointer to another, useful in opaque pointers.

There is nothing much we can really do here, that is how C APIs work.

On the other hand, when we leave so many un-resolved smells on purpose, do we have a way to go about it at the moment? This can be easily forgotten, or at least the reasoning behind it. Maybe @Jerry-Jinfeng-Guo or @mgovers can comment on this?

yeah.... this has been on my mind as well... Personally, I think we should use either char* or std::byte* internally instead of void* for anything other than the C API itself. Then, all our reinterpret_casts can be contained in a single location in the C API and no-where else. This would also remove all ambiguity regarding the sizeof(void) vs sizeof(char) vs sizeof(<Object>).

This is a team decision, though.

* @brief Destroy the converter and free up the memory that was dedicated to it.
* @param converter_ptr A pointer to a PGM_VNF_converter instance.
*/
PGM_IO_API void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

Suggested change
PGM_IO_API void PGM_VNF_delete_Converter(PGM_IO_VnfConverter* converter_ptr);
PGM_IO_API void PGM_VNF_delete_converter(PGM_IO_VnfConverter* converter_ptr);

@figueroa1395
Copy link
Contributor

This is a team decision, though.

Maybe we can bring this up as an action point to discuss in a knowledge sharing session. Definitely we should try to contain reinterpret_cast within the C APIs. It is too dangerous to have it in as many places as we do now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants